/**
解析json
 *WangGANG
 *2018/9/28
 */
package main

import (
	"encoding/json"
	"fmt"
	"bean"
	"tool"
)

const FILE  =  "src/json/TextJson.json"

func main() {
	var s bean.ServersJson

	//str := `{"servers":[{"serverName":"shanghai_VPN","serverIP":"127.0.0.1"},{"serverName":"beijing_VPN","serverIP":"127.0.0.2"}]}`
	//json.Unmarshal([]byte(str),&s)

	//读取文件
	data := tool.FileRead(FILE)

	//解析json文件内容
	json.Unmarshal(data,&s)

	fmt.Println(s)
	fmt.Println(s.Servers)
	for _,aa := range s.Servers {
		fmt.Println(aa.ServerName)
	}
}